﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;

namespace skydream
{
    /// <summary>
    /// 文件帮助
    /// </summary>
    public class FilePath
    {
        //
        // 摘要:
        //     得到路径
        //
        // 返回结果:
        //     返回系统当前运行的路径。
        public static string getRunPath()
        {
            string str = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
            return str;
        }
        //
        // 摘要:
        //     得到文件
        //
        // 返回结果:
        //     返回系统当前运行的路径的文件。
        public static string getRunFile(string filename)
        {
            string str = getRunPath() + "\\" + filename;
            return str;
        }
        /// <summary>
        ///  得到目录中运行环境下的文件以结尾方式查询
        /// 文件字符组
        /// </summary>
        /// <returns></returns>
        public static string[] getFiles(String pcPath,string lastFileName)
        {
            string[] arrFile = System.IO.Directory.GetFiles(pcPath, lastFileName);
            return arrFile;
        }
        /// <summary>
        /// 指定到某个文件的
        /// 
        /// </summary>
        /// <returns></returns>
        //public static string openFileDilog(string iniDirect,string filter)
        //{
        //    openFileDialog1 = new OpenFileDialog();
        //    openFileDialog1.InitialDirectory = @"c:\";
        //    //注意这里写路径时要用c:\\\\而不是c:\\
        //    openFileDialog1.Filter = "文本文件|*.txt|所有文件|*.*";
        //    openFileDialog1.RestoreDirectory = true;
        //    openFileDialog1.FilterIndex = 1;
        //    String fName = null;
        //    if (openFileDialog1.ShowDialog() == DialogResult.OK)
        //    {
        //        fName = openFileDialog1.FileName;
        //        this.textBox3.Text = fName;
        //    }
        //    return fName;
        //}
        /// <summary>
        /// 指定到某个文件夹的
        /// 
        /// </summary>
        /// <returns></returns>
        //public static string openFileDilog(string iniDirect,string filter)
        //{
        //    folderBrowserDialog1 = new FolderBrowserDialog();
                //folderBrowserDialog1.Description = "请选择保存TXT的文件夹"; 

                //if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                //{
                //    String path = folderBrowserDialog1.SelectedPath;
                //    this.t_txt_out.Text = path;
                //}
        //}
    }
}
